package com.rabbitmq.routing;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.utils.RabbitMqUtils;

import java.io.IOException;

/**
 * @author lipengwei
 */
public class Provider {

    public static void main(String[] args) throws IOException {
        Connection connection = RabbitMqUtils.getConnection();
        Channel channel = connection.createChannel();
        channel.exchangeDeclare("logs_direct", "direct");
        // 发送消息
        String routingKey= "error";

        channel.basicPublish("logs_direct", routingKey, null,
                ("这是direct模型发布的基于 router key：" + routingKey).getBytes());

        RabbitMqUtils.closeChannelAndConnection(channel, connection);
    }
}
